#!/bin/bash
rootdir=`pwd|tr -d '\n'`

pydir=$rootdir/src/python
dataroot=$rootdir/data
zhidaoroot=$dataroot/zhidao
zhidaoxmldir=$zhidaoroot/xml
zhidaopagedir=$zhidaoroot/page

mkdir -p $dataroot
mkdir -p $rootdir
mkdir -p $zhidaopagedir

for(( i=0; i<31; i++))
do
	point=`expr $i '*' '25'`
	urls=`$pydir/listurl.py "http://zhidao.baidu.com/browse/778?lm=0&pn=${point}" "/question/.*"`
	echo "list the url http://zhidao.baidu.com/browse/778?lm=0&pn=${point}"
	
	for url in ${urls}
	do
		file=`$pydir/quote.py http://zhidao.baidu.com${url}|tr '\n' ' '`
		echo tearing the page $url into file $file
		$pydir/tear.py `$pydir/unquote.py ${file}|tr '\n' ' '` $zhidaopagedir/${file}&
		sleep 1
	done

done
